/**
 * 成员分组页
 */
(function(){
	com.hp.demo.vteam.components.AccountGroup = Ext.extend(Ext.Panel,{
		flex:1,
		fullscreen:true,
		layout:'fit',
		initComponent:function()
		{
			Ext.apply(this,{
				items:{
					xtype:'grid',
					colModel:[
						{header:com.hp.demo.vteam.dict.FIELDS.ACCOUNT_GROUP_NAME,mapping:'name'},
						{header:com.hp.demo.vteam.dict.FIELDS.ACCOUNT_GROUP_DESC,mapping:'desc'},
						{header:com.hp.demo.vteam.dict.FIELDS.ACCOUNT_GROUP_AUTHOR,mapping:'addedBy.email'}
					],
					store:com.hp.demo.vteam.base.QueryPageStore({
						url:com.hp.demo.vteam.dict.REQUEST.AccountGroup,
						model:'AccountGroup',
						errorMsg:com.hp.demo.vteam.dict.ERRORS.QUERY_ACCOUNT_GROUP_SYS
					}),
					pagenation:[
						{id:'create'},
						{id:'modify'},
						{id:'remove'}
					],
					create:function()
					{
						com.hp.demo.vteam.base.Action('CreateAccountGroup',com.hp.demo.vteam.dict.FUNC_TITLE.CreateInfoKind);
					},
					modify:function()
					{
						var items = this.dataview;
						if(items.getSelectionCount() == 0)
						{
							com.hp.demo.vteam.base.status_msg(com.hp.demo.vteam.dict.ERRORS.CHOOSEN_LEAST_ONE);
						}
						else
						{
							var record = items.getSelectedRecords()[0];
							com.hp.demo.vteam.base.Action('ModifyAccountGroup',
								com.hp.demo.vteam.dict.FUNC_TITLE.ModifyAccountGroup,
								{'accountGroup':record}
							);
						}
					},
					remove:function()
					{
						var context = this,
						    items = context.dataview;
						if(items.getSelectionCount() == 0)
						{
							com.hp.demo.vteam.base.status_msg(com.hp.demo.vteam.dict.ERRORS.CHOOSEN_LEAST_ONE);
						}
						else
						{
							var record = items.getSelectedRecords()[0];
							Ext.Ajax.request({
								url:com.hp.demo.vteam.dict.REQUEST.AccountGroup,
								params:{
									method:'del',
									id:record.get('id')
								},
								success:function(){
									com.hp.demo.vteam.base.status_msg(com.hp.demo.vteam.dict.SUCCESSES.DELETE_INFO_KIND);
									setTimeout(function(){
										context.loadData();
									},1000);
								},
								failure:function(){
									com.hp.demo.vteam.base.status_msg(com.hp.demo.vteam.dict.ERRORS.DELETE_INFO_KIND_SYS);
								}
							});
						}
					}
				}
			});
			com.hp.demo.vteam.components.AccountGroup.superclass.initComponent.call(this);
		}
	});
	return com.hp.demo.vteam.components.AccountGroup;
})();